package com.aidenj.controller;

import com.aidenj.model.User;
import com.aidenj.model.ChannelInfo;
import com.aidenj.service.ChannelInfoService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Ostrich on 12/21.
 */
@RestController
@RequestMapping("/test")
public class TestBootCountroller {

    @Autowired
    private ChannelInfoService channelInfoService;


    /**
     * 测试
     * @param user
     * @return
     */
    @RequestMapping("/find")
    @ResponseBody
    public User findUserTest(User user){
        System.out.println("前台传递参数："+user.toString());
        return user;
    }

    /**
     * 条件过去数据
     * @param channelInfo
     * @return
     */
    @RequestMapping("/channel")
    @ResponseBody
    public ChannelInfo findChnneInfo(ChannelInfo channelInfo){
        return channelInfoService.selectByPrimaryKey(channelInfo);
    }

    /**
     * 分页获取数据
     * @param channelInfo
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("/channelPage")
    @ResponseBody
    public List<ChannelInfo> findPageChannelInfo(ChannelInfo channelInfo, Integer pageNum,Integer pageSize){
        return  channelInfoService.fandPageChannelInfo(channelInfo, pageNum, pageSize);
    }

}
